package com.future.bantang.view;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * Created by Administrator on 16-1-16.
 * work by liufujie
 * 设置viewpager是否可以滑动
 */
public class ViewPagerUp extends ViewPager {

    private boolean isCanSrcoll = true;

    public ViewPagerUp(Context context) {
        super(context);
    }

    public ViewPagerUp(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public boolean isCanSrcoll() {
        return isCanSrcoll;
    }

    /**
     * 设置是否可以滑动
     *
     * @param isCanSrcoll
     */
    public void setIsCanSrcoll(boolean isCanSrcoll) {
        this.isCanSrcoll = isCanSrcoll;
    }

    /**
     * 控制滑动
     *
     * @param ev
     * @return
     */
    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        if (!isCanSrcoll) {
            return true;
        }
        return super.onTouchEvent(ev);
    }
}
